package com.dbc;

import java.sql.*;

public class DatabaseConnection {
	private static final String DRIVER = "com.mysql.jdbc.Driver";
	private static final String URL = "jdbc:mysql://localhost:3306/dormitory";
	private static final String USER = "root";
	private static final String PASSWORD = "111111";
	private Connection conn = null;

	public DatabaseConnection() throws Exception {
		Class.forName(DRIVER);
		this.conn = DriverManager.getConnection(URL, USER, PASSWORD);
	}

	public Connection getConnection() {
		return this.conn;
	}

	public void close() throws Exception {
		if (this.conn != null) {
			try {
				this.conn.close();
			} catch (Exception e) {
				throw e;
			}
		}
	}

}
